module.exports = function(sucess,error){
    if(typeof error !=='function'){
        error = ()=>{
            console.log('链接失败')
        }
    }
    const mongoose = require('mongoose')
    mongoose.connect('mongodb://lcc:123456@127.0.0.1:27017/book')
    mongoose.connection.once('open',()=>{
        console.log('连接成功')
        sucess()
    })
    mongoose.connection.on('error',()=>{
        error()
    })
    mongoose.connection.on('close',()=>{
        console.log('断开连接')
    })
}